﻿@using cloudscribe.Web.Pagination
@using conan.Saas
@using conan.Saas.Controllers
@using dotNET.Domain.Entities
@using  dotNET.Dto
@using conan.Saas.Model
@{
    Layout = "_Layoutlist";

    Departmentlistmodel ItemsDatalistmodel = ViewBag.ItemsData as Departmentlistmodel;


    List<Department> ItemsDatalist = new List<Department>();
    if (ItemsDatalistmodel != null  && ItemsDatalistmodel.Departmentlist!=null)
    {

        ItemsDatalist = ItemsDatalistmodel.Departmentlist;
    }



    DepartmentOption filer = ViewBag.filter as DepartmentOption;



}

@section headers{
    <environment names="Development">
        <link href="/lib/wdtree/tree.css" rel="stylesheet" asp-append-version="true"/>
    </environment>
    <environment names="Staging,Production">
        <link href="/lib/wdtree/tree.min.css" rel="stylesheet" asp-append-version="true"/>
    </environment>
    <style type="text/css">
        .fixed-table-toolbar {
            padding:0 15px;
        }
        .fixed-table-body {
            border-top: solid 1px #ddd;
        }
        .ui-layout .west-Panel {
            background: #fff;
            /* border: 1px solid #ccc; */
            padding: 0;
        }

        .ui-layout .center-Panel {
            /*border: 1px solid #ccc;*/
            background: #fff;
        }

    </style>
}


<section class="content">

    <div class="ui-layout ui-layout-container">
        <input type="hidden" name="treevalue" id="treevalue" value='[{ "checkstate": 0, "id": "1", "text": "学历", "value": "1", "img": "", "parentnodes": "0", "showcheck": false, "isexpand": true, "complete": true, "hasChildren": true, "childNodes": [{ "checkstate": 0, "id": "853873541967908864", "text": "本科", "value": "853873541967908864", "img": "", "parentnodes": "1", "showcheck": false, "isexpand": true, "complete": true, "hasChildren": true, "childNodes": [{ "checkstate": 0, "id": "856811634257956864", "text": "3232", "value": "856811634257956864", "img": "", "parentnodes": "853873541967908864", "showcheck": false, "isexpand": true, "complete": false, "hasChildren": false, "childNodes": [] }, { "checkstate": 0, "id": "857043719077629952", "text": "8787", "value": "857043719077629952", "img": "", "parentnodes": "853873541967908864", "showcheck": false, "isexpand": true, "complete": false, "hasChildren": false, "childNodes": [] }, { "checkstate": 0, "id": "857044075140485120", "text": "87887", "value": "857044075140485120", "img": "", "parentnodes": "853873541967908864", "showcheck": false, "isexpand": true, "complete": false, "hasChildren": false, "childNodes": [] }, { "checkstate": 0, "id": "857048612849192960", "text": "lklk", "value": "857048612849192960", "img": "", "parentnodes": "853873541967908864", "showcheck": false, "isexpand": true, "complete": false, "hasChildren": false, "childNodes": [] }] }, { "checkstate": 0, "id": "856803544573808640", "text": "111", "value": "856803544573808640", "img": "", "parentnodes": "1", "showcheck": false, "isexpand": true, "complete": false, "hasChildren": false, "childNodes": [] }, { "checkstate": 0, "id": "856803656909852672", "text": "7676", "value": "856803656909852672", "img": "", "parentnodes": "1", "showcheck": false, "isexpand": true, "complete": false, "hasChildren": false, "childNodes": [] }, { "checkstate": 0, "id": "856804359187337216", "text": "788787", "value": "856804359187337216", "img": "", "parentnodes": "1", "showcheck": false, "isexpand": true, "complete": false, "hasChildren": false, "childNodes": [] }] }, { "checkstate": 0, "id": "2", "text": "民族", "value": "2", "img": "", "parentnodes": "0", "showcheck": false, "isexpand": true, "complete": false, "hasChildren": false, "childNodes": [] }]' />
        <div class="ui-layout-west" style="width:200px;float:left;">
            <div class="west-Panel" style="border: 0px solid #ccc;">
                <div class="panel-Title" style="border-bottom: 1px solid #ccc;  font-weight:bold;">功能目录</div>

                <div id="itemTree"></div>
            </div>
        </div>

        <div class="ui-layout-center" style="width:calc(100% - 208px);float:right;">
            <div class="center-Panel" style="border: 0px solid #ccc;">
                <div class="panel-Title" style="border-bottom: 1px solid #ccc; font-weight:bold;">功能信息</div>

                <div class="titlePanel">
                    <div id="toolbar">
                        <div class="search row">
                            <div class="col-sm-12 form-group">
                                <div class="form-inline">
                                    <form action="/Department/index" method="get" id="searchform">

                                   
                                        <input type="hidden" id="ParentId" name="ParentId" value="@filer.ParentId">
                                        <div class="form-group ">
                                            <label class="control-label  label-lg label-md">名称:</label>
                                            @Html.TextBox("Name", @filer.Name, new { placeholder = "名称", @class = "form-control input-small input-sm" })
                                        </div>



                                        <span class="form-group btn-group">
                                            <button class="btn btn-sm btn-info" id="btnSearch" type="submit"><i class="fa fa-search"></i> 搜索</button>
                                        </span>
                                    </form>
                                </div>
                            </div>
                        </div>
                       
                        <div style="  position: relative;
            margin-top: 10px;
            margin-bottom: 10px;
            line-height: 34px;">
                            <div id="toolbar" class="btn-group">


                                <button id="btn_add" type="button" class="btn btn-default">

                                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
                                </button>

                            
                            </div>

                        </div>
                    </div>
                </div>

                <div class="gridPanel">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr class="heading">
                                <th>Id</th>
                              
                                <th>名称</th>
                                <th> 代码</th>
                                <th>负责人</th>
                                <th>  联系电话</th>
                                <th>  创建时间</th>
                                <th> 备注</th>

                              
                               
                                
                              
                               



                                <th style="width:120px">操作</th>
                            </tr>
                        </thead>
                        <tbody id="tbody">


                            @if (ItemsDatalist!=null  &&  ItemsDatalist.Count > 0)
                            {
                                @foreach (var s in ItemsDatalist)
                                {
                                    <tr>
                                        <td>@s.Id</td>
                                        <td>@s.Name</td>
                                        <td>@s.Code</td>

                                        <td>@s.Manager</td>
                                        <td>@s.ContactNumber</td>



                                       
                                        <td>@(s.CreatorTime.ToString("yyyy/MM/dd HH:mm:ss") ) </td>

                                        <td>@(s.Remarks)</td>

                                        <td>
                                            <a href="javascript:void(0);" onclick="btndelete('@s.Id');" class="aDel">删除</a>

                                        


                                            <a href="/Department/Edit?Id=@s.Id">编辑</a>
                                        </td>
                                    </tr>
                                }
                            }
                        </tbody>
                    </table>


                </div>

            </div>
        </div>

    </div>
</section>
    @section scripts{
        <script src="~/lib/wdtree/tree.min.js"></script>
        <script type="text/javascript">

           

        $("#btn_add").click(function () {
            location.href = "/Department/Create";
        });
  

       
            $(function () {
             
                var w = $(window).width() - 30 - 200 - 8;
                $('.west-Panel,.center-Panel').height(top.App.getIframeLayoutHeight() - 35);

              


           

            
                loadTree();
            });
          
        



            var loadTree = function () {

                var pid = $('#ParentId').val();
                $("#itemTree").treeview({
                    url: "/Department/loadtree?ParentId=" + $('#ParentId').val(),
                    onnodeclick: function (item) {
                        $("#ParentId").val(item.id);
                        $('#btnSearch').trigger("click");
                    }
                });

                $("#itemTree_" + pid).addClass("bbit-tree-selected");




            };


            //删除
            function btndelete(id) {

                layer.confirm("确定删除", { title: "删除" }, function (index) {

                    $.ajax({
                        url: "/Department/Delete?id=" + id,
                        type: "POST",
                        cache: false,
                        success: function (r) {
                            if (r.isSucceeded == true) {
                                location.href = location.href;
                            }
                            else  // 其他问题
                            {
                                $.MsgBox.Alert(r.message);
                            }
                        },
                        error: function () {

                            $.MsgBox.Alert("操作失败", "提示");
                        }
                    });

                    layer.close(index);
                });
            }

        </script>
    }


